package guiobj;


import gui.MainPanel;


import utils.Utils;

import com.google.gson.Gson;

import jsonobj.ClusterIDInfo;
import jsonobj.JSonObj;

public class SubmitPanelInfo implements JSonObj{
	public String jname;
	public String filedir;
	public String resdir;
	public int nodes;
	public int procs;
	public String walltime;
	public String exec;
	public int opt;
	public int trange;
	public String clu = null;
	
	public void getInfo(MainPanel p) {
		jname = p.jTextField3.getText();
		filedir =  p.jTextField1.getText();
		resdir = p.jTextField2.getText();
		exec = p.jTextField4.getText();
		nodes = (Integer)p.nodesSpinner.getValue();
		procs = (Integer)p.procSpinner.getValue();
		if(p.optRadio.isSelected())
		{
			opt = p.optCombo.getSelectedIndex();
			trange = (Integer) p.jSpinner1.getValue();
		}
		else
		{
			String n = p.cluCombo.getSelectedItem().toString();
			for(ClusterIDInfo i : Utils.ui.cinfo)
			{
				if(i.local_hostname.equals(n))
				{
					clu = i.hostname;
					break;
				}
			}
		}
		walltime = p.wtHours.getText()+":"+p.wtMin.getText()+":"+p.wtSec.getText();
	}
	
	public String toString()
	{
		return CLI_JOB_SUB+"|"+ new Gson().toJson(this);
	}
	
	public static SubmitPanelInfo fromJSon(String json)
	{
		return new Gson().fromJson(json,SubmitPanelInfo.class);
	}
	
}
